auto();
app.launch("com.netease.yokaikoya")

const HEIGHT = 2340;
const WIDTH = 1080;
setScreenMetrics(WIDTH, HEIGHT);

function rand(number, percent) {
    var dia = Math.floor(Math.random() * (number * percent));
    var result = number + ((Math.random() > 0.5) ? dia : -dia);
    log(number, '==>', result);
    return result;
}

var rand_low = function (number) {
    return rand(number, 0.01);
}
var rand_high = function (number) {
    return rand(number, 0.02);
}

click(100, 2200);
sleep(1000);
click(300, 2000);
sleep(1000);
click(550, 1200);
sleep(1000);
click(550, 1500);
sleep(1000);
for (var i = 0; i < 3; i++) {
    click(700, 1900);
    sleep(5000);

    click(550, 2200);
    sleep(1000);

    click(50, 1950);
    sleep(5000);

    var x = 608;
    var y = 1366;
    var dx = 70;
    var dy = 321;
    swipe(x, y, x + dx, y + dy, 1500);
    sleep(5000);


    var x = 754;
    var y = 1413;
    var dx = -265;
    var dy = 266;
    swipe(x, y, x + dx, y + dy, 1500);
    sleep(5000);


    var x = 809;
    var y = 1351;
    var dx = -137;
    var dy = 278;
    swipe(x, y, x + dx, y + dy, 1500);
    sleep(5000);


    var x = 811;
    var y = 1484;
    var dx = -53;
    var dy = 221;
    swipe(x, y, x + dx, y + dy, 1500);
    sleep(10000);

    click(550, 1500);
    sleep(10000);
}